﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using MySql.Data.MySqlClient;

namespace Scenario.Modules.PCM.Database
{
    public class BasicBusinessObjectCollection : CollectionBase, bOS.DataBase.bOSTable
    {
        public BasicBusinessObjectCollection()
        {
        }

        public BasicBusinessObject this[int index]
        {
            get { return ((BasicBusinessObject)List[index]); }
            set { List[index] = value; }
        }

        public int Add(BasicBusinessObject value)
        {
            return (List.Add(value));
        }

        public int IndexOf(BasicBusinessObject value)
        {
            return (List.IndexOf(value));
        }

        public void Insert(int index, BasicBusinessObject value)
        {
            List.Insert(index, value);
        }

        public void Remove(BasicBusinessObject value)
        {
            List.Remove(value);
        }

        public bool Contains(BasicBusinessObject value)
        {
            return (List.Contains(value));
        }

        public void ReadFromDataBase(MySqlDataReader reader)
        {
            BasicBusinessObject bo = null;

            try
            {
                while (reader.Read())
                {
                    bo = new BasicBusinessObject();

                    bo.ReadFromDataBase(reader);

                    this.Add(bo);
                }
            }
            catch (MySqlException)
            {
            }
            catch (Exception)
            {
            }
        }
    }
}
